﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1040001, 0),
Array("", 1040005, 0),
Array("", 1040027, 0),
Array("", 1040045, 0),
Array("", 1040046, 0),
Array("", 1040047, 0),
Array("", 1040051, 0),
Array("", 1040052, 0),
Array("", 1040053, 0),
Array("", 1040054, 0),
Array("", 1040055, 0),
Array("", 1040056, 0),
Array("", 1040064, 0),
Array("", 1040065, 0),
Array("", 1040066, 0),
Array("", 1040077, 0),
Array("", 1040078, 0),
Array("", 1040101, 0),
Array("", 1040114, 0),
Array("", 1040119, 0),
Array("", 1040123, 0),
Array("", 1040124, 0),
Array("", 1040125, 0),
Array("", 1040126, 0),
Array("", 1040127, 0),
Array("", 1040128, 0),
Array("", 1040129, 0),
Array("", 1040130, 0),
Array("", 1040131, 0),
Array("", 1040132, 0),
Array("", 1040133, 0),
Array("", 1040134, 0),
Array("", 1040135, 0),
Array("", 1040137, 0),
Array("", 1040138, 0),
Array("", 1040139, 0),
Array("", 1040140, 0),
Array("", 1040141, 0),
Array("", 1040144, 0),
Array("", 1040154, 0),
Array("", 1040186, 0),
Array("", 1041000, 0),
Array("", 1041001, 0),
Array("", 1041005, 0),
Array("", 1041009, 0),
Array("", 1041070, 0),
Array("", 1041071, 0),
Array("", 1041072, 0),
Array("", 1041073, 0),
Array("", 1041090, 0),
Array("", 1041104, 0),
Array("", 1041108, 0),
Array("", 1041109, 0),
Array("", 1041110, 0),
Array("", 1041111, 0),
Array("", 1041112, 0),
Array("", 1041113, 0),
Array("", 1041114, 0),
Array("", 1041125, 0),
Array("", 1041126, 0),
Array("", 1041127, 0),
Array("", 1041128, 0),
Array("", 1041129, 0),
Array("", 1041130, 0),
Array("", 1041131, 0),
Array("", 1041132, 0),
Array("", 1041133, 0),
Array("", 1041134, 0),
Array("", 1041135, 0),
Array("", 1041136, 0),
Array("", 1041137, 0),
Array("", 1041138, 0),
Array("", 1041139, 0),
Array("", 1041140, 0),
Array("", 1041142, 0),
Array("", 1041143, 0),
Array("", 1041144, 0),
Array("", 1041147, 0),
Array("", 1041156, 0),
Array("", 1041189, 0),
Array("", 1042000, 0),
Array("", 1042001, 0),
Array("", 1042002, 0),
Array("", 1042004, 0),
Array("", 1042005, 0),
Array("", 1042006, 0),
Array("", 1042007, 0),
Array("", 1042008, 0),
Array("", 1042009, 0),
Array("", 1042010, 0),
Array("", 1042011, 0),
Array("", 1042012, 0),
Array("", 1042013, 0),
Array("", 1042014, 0),
Array("", 1042015, 0),
Array("", 1042016, 0),
Array("", 1042017, 0),
Array("", 1042018, 0),
Array("", 1042019, 0),
Array("", 1042020, 0),
Array("", 1042021, 0),
Array("", 1042022, 0),
Array("", 1042023, 0),
Array("", 1042024, 0),
Array("", 1042025, 0),
Array("", 1042026, 0),
Array("", 1042029, 0),
Array("", 1042030, 0),
Array("", 1042031, 0),
Array("", 1042032, 0),
Array("", 1042033, 0),
Array("", 1042034, 0),
Array("", 1042035, 0),
Array("", 1042036, 0),
Array("", 1042037, 0),
Array("", 1042038, 0),
Array("", 1042039, 0),
Array("", 1042040, 0),
Array("", 1042041, 0),
Array("", 1042042, 0),
Array("", 1042043, 0),
Array("", 1042044, 0),
Array("", 1042045, 0),
Array("", 1042046, 0),
Array("", 1042047, 0),
Array("", 1042048, 0),
Array("", 1042049, 0),
Array("", 1042050, 0),
Array("", 1042051, 0),
Array("", 1042052, 0),
Array("", 1042053, 0),
Array("", 1042054, 0),
Array("", 1042055, 0),
Array("", 1042056, 0),
Array("", 1042058, 0),
Array("", 1042059, 0),
Array("", 1042060, 0),
Array("", 1042061, 0),
Array("", 1042062, 0),
Array("", 1042063, 0),
Array("", 1042066, 0),
Array("", 1042067, 0),
Array("", 1042068, 0),
Array("", 1042069, 0),
Array("", 1042070, 0),
Array("", 1042071, 0),
Array("", 1042072, 0),
Array("", 1042073, 0),
Array("", 1042074, 0),
Array("", 1042075, 0),
Array("", 1042076, 0),
Array("", 1042077, 0),
Array("", 1042078, 0),
Array("", 1042080, 0),
Array("", 1042081, 0),
Array("", 1042082, 0),
Array("", 1042083, 0),
Array("", 1042084, 0),
Array("", 1042085, 0),
Array("", 1042086, 0),
Array("", 1042087, 0),
Array("", 1042088, 0),
Array("", 1042089, 0),
Array("", 1042090, 0),
Array("", 1042091, 0),
Array("", 1042092, 0),
Array("", 1042093, 0),
Array("", 1042094, 0),
Array("", 1042095, 0),
Array("", 1042096, 0),
Array("", 1042097, 0),
Array("", 1042098, 0),
Array("", 1042099, 0),
Array("", 1042100, 0),
Array("", 1042101, 0),
Array("", 1042102, 0),
Array("", 1042103, 0),
Array("", 1042104, 0),
Array("", 1042105, 0),
Array("", 1042106, 0),
Array("", 1042107, 0),
Array("", 1042108, 0),
Array("", 1042109, 0),
Array("", 1042110, 0),
Array("", 1042116, 0),
Array("", 1042117, 0),
Array("", 1042118, 0),
Array("", 1042119, 0),
Array("", 1042120, 0),
Array("", 1042121, 0),
Array("", 1042122, 0),
Array("", 1042125, 0),
Array("", 1042126, 0),
Array("", 1042127, 0),
Array("", 1042128, 0),
Array("", 1042129, 0),
Array("", 1042130, 0),
Array("", 1042131, 0),
Array("", 1042132, 0),
Array("", 1042133, 0),
Array("", 1042134, 0),
Array("", 1042135, 0),
Array("", 1042136, 0),
Array("", 1042137, 0),
Array("", 1042138, 0),
Array("", 1042140, 0),
Array("", 1042142, 0),
Array("", 1042143, 0),
Array("", 1042144, 0),
Array("", 1042145, 0),
Array("", 1042146, 0),
Array("", 1042147, 0),
Array("", 1042149, 0),
Array("", 1042150, 0),
Array("", 1042151, 0),
Array("", 1042152, 0),
Array("", 1042153, 0),
Array("", 1042154, 0),
Array("", 1042155, 0),
Array("", 1042156, 0),
Array("", 1042157, 0),
Array("", 1042158, 0),
Array("", 1042159, 0),
Array("", 1042160, 0),
Array("", 1042161, 0),
Array("", 1042162, 0),
Array("", 1042163, 0),
Array("", 1042164, 0),
Array("", 1042165, 0),
Array("", 1042166, 0),
Array("", 1042168, 0),
Array("", 1042169, 0),
Array("", 1042170, 0),
Array("", 1042172, 0),
Array("", 1042173, 0),
Array("", 1042174, 0),
Array("", 1042176, 0),
Array("", 1042177, 0),
Array("", 1042178, 0),
Array("", 1042181, 0),
Array("", 1042182, 0),
Array("", 1042183, 0),
Array("", 1042184, 0),
Array("", 1042185, 0),
Array("", 1042186, 0),
Array("", 1042187, 0),
Array("", 1042188, 0),
Array("", 1042189, 0),
Array("", 1042190, 0),
Array("", 1042193, 0),
Array("", 1042194, 0),
Array("", 1042198, 0),
Array("", 1042199, 0),
Array("", 1042200, 0),
Array("", 1042202, 0),
Array("", 1042203, 0),
Array("", 1042204, 0),
Array("", 1042206, 0),
Array("", 1042207, 0),
Array("", 1042208, 0),
Array("", 1042209, 0),
Array("", 1042210, 0),
Array("", 1042212, 0),
Array("", 1042213, 0),
Array("", 1042214, 0),
Array("", 1042215, 0),
Array("", 1042216, 0),
Array("", 1042217, 0),
Array("", 1042218, 0),
Array("", 1042219, 0),
Array("", 1042220, 0),
Array("", 1042221, 0),
Array("", 1042222, 0),
Array("", 1042230, 0),
Array("", 1042232, 0),
Array("", 1042235, 0),
Array("", 1042236, 0),
Array("", 1042237, 0),
Array("", 1042238, 0),
Array("", 1042239, 0),
Array("", 1042240, 0),
Array("", 1042241, 0),
Array("", 1042242, 0),
Array("", 1042251, 0),
Array("", 1048000, 0),
Array("", 1048001, 0),
Array("", 1048002, 0),
Array("", 1049000, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到时尚上衣店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}